<html>
<head><meta charset="utf-8"><title>Optimizing away 3 allocations at runtime startup · t-libs · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/index.html">t-libs</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Optimizing.20away.203.20allocations.20at.20runtime.20startup.html">Optimizing away 3 allocations at runtime startup</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="241133442"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Optimizing%20away%203%20allocations%20at%20runtime%20startup/near/241133442" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Optimizing.20away.203.20allocations.20at.20runtime.20startup.html#241133442">(Jun 02 2021 at 11:00)</a>:</h4>
<p>It seems there're three allocations at rt startup time, all of them associated with the main thread <code>Thread</code> value being set up.</p>
<p>Is it a good idea to optimize these away?</p>



<a name="241137107"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Optimizing%20away%203%20allocations%20at%20runtime%20startup/near/241137107" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Steven Fackler <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Optimizing.20away.203.20allocations.20at.20runtime.20startup.html#241137107">(Jun 02 2021 at 11:43)</a>:</h4>
<p>What would the benefit be?</p>



<a name="241137499"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Optimizing%20away%203%20allocations%20at%20runtime%20startup/near/241137499" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Thom Chiovoloni <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Optimizing.20away.203.20allocations.20at.20runtime.20startup.html#241137499">(Jun 02 2021 at 11:49)</a>:</h4>
<p>im not really going to go to bat for this since it seems pretty hard, and is still less pain than c allocators that want to replace malloc/free need to deal with, but one reason would be: it would be nice if #[global_allocator] impls didnt have to worry about allocs prior to main.</p>



<a name="241159470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/Optimizing%20away%203%20allocations%20at%20runtime%20startup/near/241159470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/Optimizing.20away.203.20allocations.20at.20runtime.20startup.html#241159470">(Jun 02 2021 at 14:47)</a>:</h4>
<p>And maybe get the whole allocator stuff optimized away if memory allocations are not used at all in user program?</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>